#!/usr/local/bin/python
# -*- coding: utf-8 -*-
from django.db import models
from assoce.core.models import *


class RemboursManager(models.Model):
    activite = models.ForeignKey(Activite, related_name='rembours_mgrs', verbose_name='Activité gérant des remboursements')
    def __unicode__(self):
        return self.activite.label

class Facture(models.Model):
    activite = models.ForeignKey(Activite, verbose_name='Activité')
    membre = models.ForeignKey(Membre, null=True, blank=True, verbose_name='Adhérent')
    beneficiaires = models.ManyToManyField('Beneficiaire', null=True, blank=True, verbose_name='Bénéficiaires')

class FactureItem(models.Model):
    TYPE_CHOICES=(('1','1'),('2','2'))
    facture = models.ForeignKey(Facture)
    date = models.DateField(verbose_name='Date')
    type = models.CharField(max_length=1, choices=TYPE_CHOICES)
    label = models.CharField(max_length=100, verbose_name='Label')
    valueEuro = models.DecimalField(max_digits=6, decimal_places=2, verbose_name='valeur euros')
    valueDevise = models.DecimalField(max_digits=6, null=True, blank=True, decimal_places=2, verbose_name='valeur devise')

class Beneficiaire(models.Model):
    membre = models.ForeignKey(Membre, null=True, blank=True, verbose_name='Adhérent')
    prenom = models.CharField(max_length=100, verbose_name='Prénom')
    nom = models.CharField(null=True, blank=True, max_length=100, verbose_name='Nom')
    date = models.DateField(null=True, blank=True, verbose_name='Date de naissance')
    def __unicode__(self):
        return self.prenom
